<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
		<title></title>
		<style type="text/css">
			#box{
				width: 400px;
				height: 450px;
				border: 1px solid red;
				margin: 30px auto;
			}
		</style>
		<script type="text/javascript">
			window.onload = function(){
				var btn = document.getElementById("btn");
				var box  =document.getElementById("box");
				var one = document.getElementById("one");
				var two = document.getElementById("two");
				btn.onclick = function(){
					//获得box子节点的长度  13
//					var res = box.childNodes.length;
//					alert(res);

					//获得父节点的引用 给父级元素里的所有字体变成红色
//					one.parentNode.style.color = 'red';

					//给第一个节点上色
//					box.firstChild.style.color = 'red';

					//给最后一个节点上色
//					box.lastChild.style.color = 'red';

					//给下一个兄弟节点上色
//					two.nextSibling.style.color = 'red';

					//给上一个兄弟节点上色
					two.previousSibling.style.color = 'red';
				}
			}
		</script>
	</head>
	<body>
		<button id="btn">点我呀</button>
		<div id="box"><h1 id="one">我们都是h1标签</h1><h1 id="two">我们都是h1标签</h1><h1>我们都是h1标签</h1><h1>我们都是h1标签</h1><h1>我们都是h1标签</h1><h1>我们都是h1标签</h1></div>
	</body>
</html>
